package com.qf.util;

import java.io.IOException;
import java.util.Properties;

public class BeanFactory {
    private Properties properties=new Properties();

    public BeanFactory() {
    }

    public BeanFactory(String config) throws IOException {
       properties.load(BeanFactory.class.getResourceAsStream(config));
    }

    public Object getBean(String beanName) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        String classPath = properties.getProperty(beanName);
        if (classPath != null) {
            Class  clazz = Class.forName(classPath);
            return clazz.newInstance();
        }
        return null;
    }
}
